<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap{
	protected function _initAutoload(){
		$autoloader = new Zend_Application_Module_Autoloader(array(
				'namespace' => '',
				'basePath' => dirname(__FILE__),
		));
		return $autoloader;
	}
	protected function _initDatabase(){
		$db = $this->getPluginResource('db')->getDbAdapter();
		Zend_Registry::set('db', $db);
		$select = $db->query("SET NAMES utf8");
	}
	protected function _initPlugins(){
		$front = Zend_Controller_Front::getInstance();
		$front->registerPlugin(new Zgome_Plugins_LayoutSelector());
	}
	protected function _initFrontController(){
		$front = Zend_Controller_Front::getInstance();
		$front->addControllerDirectory(APPLICATION_PATH . "/modules/default/controllers","default");
		$front->addControllerDirectory(APPLICATION_PATH . "/modules/mobile/controllers", "mobile");
		$front->addControllerDirectory(APPLICATION_PATH . "/modules/admin/controllers", "admin");
		
	
		return $front;
	}
	protected function _initRoute(){
		$routers = Zend_Controller_Front::getInstance()->getRouter();
		$route = new Zend_Controller_Router_Route_Regex(
				'home/(.*)/(.*).html',
				array(
						'controller' => 'index',
						'action' => 'index',
						"module" => "default",
						"title" => "game-pikachu-dac-biet"
				),
				array(
						1 => 'action',
						2 => 'title'
				),
				"home/%s/%s.html"
		);
		$routers->addRoute("web", $route);
		$route = new Zend_Controller_Router_Route_Regex(
				'mhome/(.*)/(.*).html',
				array(
						'controller' => 'index',
						'action' => 'index',
						"module" => "mobile",
						"title" => "game-pikachu-dac-biet"
				),
				array(
						1 => 'action',
						2 => 'title'
				),
				"mhome/%s/%s.html"
		);
		$routers->addRoute("m", $route);
		Zend_Controller_Front::getInstance()->setRouter($routers);
		return $routers;
	}
}
?>